/**
 * 初始化病种筛查配置详情对话框
 */
var SdsQcentityRuleInfoDlg = {
    validateFields: {
    	entityId: {
            validators: {
                notEmpty: {
                    message: '质控病种不能为空'
                }
            }
        },
    	ruleType: {
            validators: {
                notEmpty: {
                    message: '准入/排除不能为空'
                }
            }
        },
    	ruleDesc: {
            validators: {
                notEmpty: {
                    message: '筛查描述不能为空'
                }
            }
        },
    	expressId: {
            validators: {
                notEmpty: {
                    message: '筛查函数不能为空'
                }
            }
        },
    	param: {
            validators: {
                notEmpty: {
                    message: '筛查入参不能为空'
                }
            }
        },
    	param2: {
            validators: {
                notEmpty: {
                    message: '预留参数不能为空'
                }
            }
        },
    	indNo: {
            validators: {
                notEmpty: {
                    message: '序号不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
SdsQcentityRuleInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdsQcentityRuleInfoDlg.validate = function () {
    $('#sdsQcentityRuleInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsQcentityRuleInfoForm').bootstrapValidator('validate');
    return $("#sdsQcentityRuleInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdsQcentityRuleInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityRuleInfoForm',Sys.backendPath + "/sds/sdsqcentityrule/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityRule.table.refresh();
        SdsQcentityRuleInfoDlg.close();
    });
}

/**
 * 提交修改
 */
SdsQcentityRuleInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityRuleInfoForm',Sys.backendPath + "/sds/sdsqcentityrule/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityRule.table.refresh();
        SdsQcentityRuleInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("sdsQcentityRuleInfoForm", SdsQcentityRuleInfoDlg.validateFields);
});
